﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;

public partial class Admin_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    //public static string mahoa(string text)
    //{
    //    MD5CryptoServiceProvider _md5Hasher = new MD5CryptoServiceProvider();
    //    byte[] bs = Encoding.UTF8.GetBytes(text);
    //    bs = _md5Hasher.ComputeHash(bs);
    //    StringBuilder s = new StringBuilder();
    //    foreach (byte b in bs)
    //    {
    //        s.Append(b.ToString("x2"));
    //    }
    //    return s.ToString();
    //}
    protected void butLogin_Click(object sender, EventArgs e)
    { /*{ 
        string matkhau;
        if (txtUser.Text.Length == 0)
        {
            txtUser.BackColor = Color.Red;
            txtUser.Focus();
        }
        else if (txtPass.Text.Length == 0)
        {
            txtPass.BackColor = Color.Red;
            txtPass.Focus();
        }
        else
        {
            matkhau = mahoa(txtPass.Text);
            clsAcount clsAc = new clsAcount(txtUser.Text, matkhau);
            int n = clsAc.checkAcount();
            if (n == 0)
                lblThongbao.Text = "Đăng nhập thất bại!";
            else if (n == 2)
            {
                Session["MaUS"] = txtUser.Text;
                Session["Quyen"] = n;
                lblThongbao.Text = "dang nhap thanh cong";

               // Response.Redirect("Menu1.aspx");
            }
            else
            {
                Session["MaUS"] = txtUser.Text;
                Session["Quyen"] = n;
                lblThongbao.Text = "dang nhap thanh ........ cong";
               // Response.Redirect("../default.aspx");
            }
            }*/
           
                 if (txtUser.Text.Length == 0)
                 {
                     txtUser.BackColor = Color.Red;
                     txtUser.Focus();
                 }
                 else if (txtPass.Text.Length == 0)
                 {
                     txtPass.BackColor = Color.Red;
                     txtPass.Focus();
                 }
                 else
                 {
                     clsAcount clsAc = new clsAcount(txtUser.Text, txtPass.Text);
                     int n = clsAc.checkAcount();
                     if (n == 0)
                         lblThongbao.Text = "Đăng nhập thất bại!";
                     else if (n == 2)
                        {
                        Session["MaUS"] = txtUser.Text;
                        Session["Quyen"] = n;
                        lblThongbao.Text = "dang nhap thanh cong";}
                     else
                     {
                         Session["MaUS"] = txtUser.Text;
                         Session["Quyen"] = n;
                         Response.Redirect("Default.aspx");
                     }
                 }
    }
}